package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;

public class Test2 {
    public static void main(String[] args) {
        //创造一个集合,里面存放10个0-100之间的随机数
        Collection<Integer> c=new ArrayList<>();
        Random r=new Random();
        for (int i=0;i<10;i++){
            c.add(r.nextInt(100)+1);
        }
        System.out.println(c);

        Iterator<Integer> it=c.iterator();
        while (it.hasNext()){
            int e= it.next();//获取下一个元素
            if (e%2==0) {
                it.remove();
            }

        }
        System.out.println(c);

    }
}
